Skip to content

Conversation

manerlan
Copy link
Member

Landing page for Kork & Krone

Refs #11

First version of the front page, which explains what the site is and leads the user into search.
Frontend only. All data is sample data (features/landing/api/mockLanding.ts) until the backend is ready.

Screenshots

Desktop Mobile (375 px)

What's added

The front page, top to bottom

  • Header: logo, «Utforsk» (Explore) and «Mine anmeldelser» (My reviews). The header search is hidden on the front page, since the hero has its own.
  • Hero: explains the concept, with a large search field with a visible label, and suggestions that link into search.
  • Key figures: number of wines, community ratings and student reviews.
  • «Slik fungerer Kork & Krone» (How it works): search, compare and give your verdict.
  • Categories: wine types that link to /sok?type=….
  • «Medstudentenes favoritter» (Fellow students' favourites): wine cards with the student rating, the community rating and a «Vil prøve» (Want to try) button.
  • «Nylig dømt» (Recently reviewed): the latest reviews with dice rating and comment.
  • Footer: «Drikk med måte» (Drink responsibly) and the X-Wines data source.

Shared foundation for reuse

  • Design tokens in styles/tokens.css: wine red and cork beige, a pastel colour per wine type, and dark mode.
  • UI components in components/ui: WineCard, SearchForm, Bottle, DiceFace and Chip. The wine card and search field are built to be reused on the search page.
  • Layout in components/layout: AppLayout, Header and Footer.
  • Routes with React Router, with basename taken from Vite's base: /, /sok, /vin/:id, /mine and 404. Pages are loaded with React.lazy.
  • Search state in the URL: buildSearchUrl and parseSearchParams in lib/searchParams.ts are the contract between the front page and the search page: ?q=&type=&land=&drue=&mat=&sort=.

Setup

  • Vitest, React Testing Library, vitest-axe and Playwright with @axe-core/playwright.
  • base: '/project2/' in vite.config.ts.
  • index.html: lang="nb", description, color-scheme and a new title.

Removed

  • The old App.tsx with the PostgreSQL greeting, and its test. It was the only check that the backend and database respond. The /api/hello proxy is still in vite.config.ts.
  • src/index.css, replaced by styles/global.css.

Testing

Type What Result
Unit tests (Vitest) URL builder, formatting, components, layout, data hook and the front page 53 tests, all passing
Accessibility (vitest-axe) Components and the front page, with and without data No violations
E2E (Playwright) Search flow, keyboard, axe against WCAG 2.1 AA and reflow at 320 px, on desktop and mobile 10 tests, all passing
Manual Keyboard navigation, search from the front page and mobile view OK
Contrast All colour pairs against WCAG AA At least 4.9:1 for text

Run it yourself:

cd frontend
npm install
npm run lint && npx tsc -b && npx vitest run && npm run build
npm run e2e        # first time: npx playwright install chromium
npm run dev        # http://localhost:5173/project2/

Accessibility

  • Skip link to main content, landmarks (header, nav, main, footer) and one h1 per page.
  • Focus moves to the page's h1 after navigation, including for lazy-loaded pages.
  • The search field has a visible label and uses role="search".
  • Ratings are always shown as text («4,6 av 5 · 23 dommer»), and the dice rating has text for screen readers.
  • «Vil prøve» is an aria-pressed button with the wine name in its accessible name.
  • The loading state is announced in a live region, and errors are shown with role="alert" and a «Prøv igjen» (Try again) button.
  • Touch targets of at least 44 px, visible focus everywhere, and prefers-reduced-motion is respected.

Sustainability

  • SVG bottles instead of product images.
  • System fonts, so no fonts are downloaded.
  • The front page is its own code chunk. Search and the detail page load only when needed.
  • The front page is designed to be fetched with a single GraphQL query (LANDING_QUERY).
  • Dark mode via prefers-color-scheme.

Dependencies

  • New: react-router (runtime) and test packages (dev).
  • npm audit fix: updated, among others, Vite to a version without known vulnerabilities.
  • Everyone needs to run npm install after pulling this branch.

Backend wiring (later)

  • Replace the body of useLandingData with useQuery(LANDING_QUERY). The code is in a comment in the file. The return shape is the same, so the components don't need to change.
  • LANDING_QUERY in features/landing/api/landingQuery.ts is a proposal the backend can implement against.
  • useWishlist stores data in the browser for now. It will be replaced by the setListStatus mutation.

For whoever builds the search page

  • features/search/SearchPage.tsx is only a placeholder. Replace it.
  • Read the search state with parseSearchParams, so the front page and the search page use the same parameters.
  • WineCard and SearchForm can be reused directly.

AI used – for what, and how was it verified?

Tool: Claude.

Used for: generating components, design tokens, tests and setup, and guidance on git and splitting the work into commits.

Changed after generation:

  • Components and helper functions in the same file were split (react-refresh/only-export-components).
  • useLandingData set state synchronously inside an effect (react-hooks/set-state-in-effect).
  • The test helper used <output>, which has an implicit role="status" and clashed with the page's live region.
  • The search field pushed the hero content off-screen on mobile.
  • The contrast of muted text was adjusted.

Verified with: lint, tsc -b, Vitest, Playwright and manual testing. Each commit was run and checked before it was added.

How to review

Go through it commit by commit. Each commit builds and has its own tests:

  1. chore(frontend): test setup
  2. chore(deps): npm audit fix
  3. feat(ui): design tokens
  4. feat(lib): URL builder and formatting
  5. feat(ui): UI components and hooks
  6. feat(layout): header, footer and focus handling
  7. fix(test): test helper without a status role
  8. feat(landing): the front page with sample data
  9. feat(app): routes and cleanup
  10. test(e2e): Playwright

Checklist

  • Tests added, and all are passing
  • Accessibility checked (axe and manually with keyboard)
  • Screenshots attached
  • AI use documented
  • Lint and typecheck are passing
Skjermbilde 2026-10-30 133643 Skjermbilde 2026-10-30 133705

@manerlan manerlan requested a review from a team as a code owner October 30, 2026 12:59
@manerlan
Copy link
Member Author

Did a lot of things here, provided through several commits. AI has been used to create a markdown which explains the relevant information regarding what has been done. Preferably look through and check over before approving and merging to main. Has been tested manually and while doing revisions underway. Images for homepage loaded weirdly, but you can still see approximates. Should be good to merge into main

Copy link
Member

@oscarba oscarba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Tested and works

@oscarba oscarba merged commit a407fc6 into dev-frontend Oct 30, 2026
@oscarba oscarba deleted the 11-initial-homepage branch October 30, 2026 14:08
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants